package org.mespilus.mespilusweb.ui.usermanagement.server;

import java.util.ArrayList;
import java.util.List;

import org.mespilus.mespilusweb.TraceFactory;
import org.mespilus.mespilusweb.datalayer.usermanagement.Member;
import org.mespilus.mespilusweb.ui.usermanagement.client.UserManagementService;
import org.mespilus.mespilusweb.ui.usermanagement.client.model.FullMember;
import org.mespilus.mespilusweb.ui.usermanagement.client.model.UsefulGroup;
import org.mespilus.mespilusweb.ui.usermanagement.client.model.UsefulMember;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;

@SuppressWarnings("serial")
public class UserManagementServiceImpl extends RemoteServiceServlet implements UserManagementService{

	@Override
	public void addGroup(UsefulGroup group) {
		TraceFactory.getInstance().register("addGroup "+group.toString());
	}

	@Override
	public List<UsefulGroup> getGroups() {
		TraceFactory.getInstance().register("getGroups");
		List<String> list = new ArrayList<String>();
		
		return null;
	}

	@Override
	public void addMember(FullMember member) {
		TraceFactory.getInstance().register("addMember "+member.toString());
		Member st_persons = new Member(member);
		Member.insert(st_persons);
	}

	@Override
	public List<UsefulMember> getMembers() {
		TraceFactory.getInstance().register("getMembers => "+Member.getUsefulMembers());
		return Member.getUsefulMembers();
	}

	@Override
	public FullMember getMember(String mail) {
		UsefulMember usefulMember = new UsefulMember();
		usefulMember.setMail(mail);
		TraceFactory.getInstance().register("getMember => "+Member.getFullMember(usefulMember));
		return Member.getFullMember(usefulMember);
	}

}
